package cqut.demo.dao.entity;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * User实体类
 * @author wuyoushan
 * @date 2016/12/25.
 */
public class User implements Serializable{
    private int id; 	 // 用户标志

    @NotBlank(message ="用户名不能为空")
    private String name; // 用户名

    @Min(value = 0,message = "年龄必须大于0")
    private Integer age;  // 年龄

    @NotNull(message = "性别不能为空")
    @Length(min =1,max =2,message = "性别长度必须大于1小于2")
    private String gender;  // 类型

    public User() {
        super();
    }

    public User(int id, String name, Integer age, String gender) {
        super();
        this.id = id;
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        return String.format("id:%d,name:%s,age:%d,gender:%s",id,name,age,gender);
    }
}
